package com.yc.star.booksystem.aespect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class TimeRecordAspect {
    @Around("execution(* com.yc.star.booksystem.controller.*.*(..))")
    public Object record(ProceedingJoinPoint pj) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = pj.proceed();
        log.info(pj.getSignature()+"cost time:"+(System.currentTimeMillis()-start));
        return result;
    }
}
